using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Clock : MonoBehaviour
{
    public List<Sprite> timeSprites;
    private int currentTimeSpriteIndex = 1;
    private Image clockSprite;
    public float timeModifier;
    public float timeToChangeSprite;
    private float currentTime;
    private float totalTime;

    private void Start()
    {
        clockSprite = GetComponent<Image>();
    }

    private void Update()
    {
        totalTime += Time.deltaTime * timeModifier;
        currentTime += Time.deltaTime * timeModifier;
        if (currentTime >= timeToChangeSprite)
        {
            if (currentTimeSpriteIndex >= timeSprites.Count)
            {
                //到点下班
                UIManager.instance.isTimeToGoHome = true;
                gameObject.GetComponent<Clock>().enabled = false;
            }
            else
            {
                clockSprite.sprite = timeSprites[currentTimeSpriteIndex];
                currentTimeSpriteIndex ++;
                currentTime = 0;
            }
        }
    }
        
}
